package com.nx.vip.javacore.reflection;


/**
 * 缺点：性能损耗
 */
public class EfficMain {

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        for(int i=0;i<1000000;i++){
//            User user = new User(); //使用构造函数创建对象
            getInstanceByRef("com.nx.vip.javacore.reflection.pojo.User");


        }

        long end = System.currentTimeMillis();
        System.out.println("总耗时"+(end-start));
    }

    private static void getInstanceByRef(String key){
        try {
            Class<?> clazz = Class.forName(key);
            clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
